#import <Foundation/Foundation.h>
#include <stdio.h>

extern int polipoInit(const char *config);
extern int polipoListenInit();
extern void polipoExit();
extern void polipoSetLog(FILE *file);
extern int polipoGetListenerSocket();
extern int polipoDoEvents();
extern int polipoClearCache();
extern int polipoForceClearCache();
extern void polipoRelease();
//extern int httptunnel_client (int port, const char *hostname, int host_port);
//extern int httptunnel_setdebug (int loglevel, FILE *logfile);

@class ProxyWrapper;

@protocol ProxyWrapperDelegate

@required

- (void)proxyWillStart:(ProxyWrapper *)p;
- (void)proxyWillStop:(ProxyWrapper *)p;
- (void)proxyDidStart:(ProxyWrapper *)p;
- (void)proxyDidStop:(ProxyWrapper *)p;
- (void)proxyDidTunnelStop:(ProxyWrapper *)p;
- (void)proxyDidFailWithError:(NSString *)error proxyWrapperInstance:(ProxyWrapper *)p;
- (void)proxyLogMessage:(NSString *)message;

@end

@interface ProxyWrapper : NSObject

@property (nonatomic, assign) id delegate;
@property (atomic) bool isRunning;
@property (readonly) NSInteger logLevel;
@property (readonly) NSString *proxyName;
@property (readonly) NSString *listenAddress;
@property (readonly) NSInteger listenPort;
@property (readonly) NSString *tunnelAddress;
@property (readonly) bool tunnelAlways;

+ (void) setPort:(int)p;
+ (int) getPort;

- (id)initWithDelegate:(id)delegate;
- (void)start;
- (void)stop;
- (void)clear;

@end
